home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
STRINGS
/
PACKAGE6
/
MAXCARD.DOC
< prev
next >
Wrap
Text File
|
1990-07-25
|
2KB
|
44 lines
-----------------------------------------------------------------------------
ReadLnMaxCardinal
-----------------------------------------------------------------------------
declaration: procedure ReadLnMaxCardinal (var CardinalNumber:
integer;
MaxCardinal:
integer;
var LastKey:
TypeKey);
purpose: Reads in numbers allowing only 0..9, Escape, Enter,
Backspace, and keeps a running tally of the number
to prevent from exceeding MaxCardinal
precondition: CardinalNumber is undefined, MaxCardinal is a positive
integer, LastKey is undefined
postcondition: CardinalNumber is set to 0 if Escape is pressed, and
keeps value if Enter is pressed, CardinalNumber <=
MaxCardinal
special cases: none
example: var Number:
integer;
var LastKey:
TypeKey;
begin
.
.
.
write (output,'Enter a number from 1..10: ');
ReadLnMaxCardinal (Number, 10, LastKey);
if LastKey <> EscapeKey then
write (output, Number);
.
.
.
end
-----------------------------------------------------------------------------